/*
 * @Author: wangzhongjie
 * @Date: 2019-01-08 10:27:08
 * @LastEditors: wangzhongjie
 * @LastEditTime: 2019-01-17 16:34:40
 * @Description: 五个专栏
 * @Email: uvdream@163.com
 */

import 'package:flutter/material.dart';
//每日新品
import './five_column/dailyProduct.dart';
class Product{
  final String title;
  final String description;
  Product(this.title,this.description);
}
// 五个专栏
class SortColumn extends StatelessWidget{
  @override
  Widget  build(BuildContext context){
    return Container(
          color: Colors.white,
          height: 70,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
                new Container(
                  width: (MediaQuery.of(context).size.width - 6.0) / 5,
                  alignment: Alignment.center,
                  child: FlatButton(
                    onPressed: (){
                        // Navigator.push(context, new MaterialPageRoute(
                        //     builder: (context)=>new DailProductPage(
                        //       products:List.generate(
                        //         20, 
                        //         (i)=>Product('商品 $i','这是一个商品详情，编号为:$i'))
                        //     )
                        // )
                        // );
                        _backContext(context);
                    },
                    child: Container(
                      padding: const EdgeInsets.fromLTRB(0, 15, 0, 0),
                      child: new Column(
                        children: <Widget>[
                          new Container(
                              child: new Container(
                                width: 30,
                                height: 30,
                                child: new Image.asset('images/home/sort1.png'),
                              ),
                            ),
                            new Container(
                              margin: const EdgeInsets.only(top:8),
                              child: new Text("每日新品", style: new TextStyle(color: Color(0xff696969), fontSize: 10.0)),
                            )
                        ],
                      ),
                    ),
                  ),
                ),
                 new Container(
                  width: (MediaQuery.of(context).size.width - 6.0) / 5,
                  alignment: Alignment.center,
                  child: FlatButton(
                    onPressed: (){},
                    child: Container(
                      padding: const EdgeInsets.fromLTRB(0, 15, 0, 0),
                      child: new Column(
                        children: <Widget>[
                          new Container(
                              child: new Container(
                                width: 30,
                                height: 30,
                                child: new Image.asset('images/home/sort2.png'),
                              ),
                            ),
                            new Container(
                              margin: const EdgeInsets.only(top:8),
                              child: new Text("小米众筹", style: new TextStyle(color: Color(0xff696969), fontSize: 10.0)),
                            )
                        ],
                      ),
                    ),
                  ),
                ),
                 new Container(
                  width: (MediaQuery.of(context).size.width - 6.0) / 5,
                  alignment: Alignment.center,
                  child: FlatButton(
                    onPressed: (){},
                    child: Container(
                      padding: const EdgeInsets.fromLTRB(0, 15, 0, 0),
                      child: new Column(
                        children: <Widget>[
                          new Container(
                              child: new Container(
                                width: 30,
                                height: 30,
                                child: new Image.asset('images/home/sort3.png'),
                              ),
                            ),
                            new Container(
                              margin: const EdgeInsets.only(top:8),
                              child: new Text("限时抢购", style: new TextStyle(color: Color(0xff696969), fontSize: 10.0)),
                            )
                        ],
                      ),
                    ),
                  ),
                ),
                 new Container(
                  width: (MediaQuery.of(context).size.width - 6.0) / 5,
                  alignment: Alignment.center,
                  child: FlatButton(
                    onPressed: (){},
                    child: Container(
                      padding: const EdgeInsets.fromLTRB(0, 15, 0, 0),
                      child: new Column(
                        children: <Widget>[
                          new Container(
                              child: new Container(
                                width: 30,
                                height: 30,
                                child: new Image.asset('images/home/sort4.png'),
                              ),
                            ),
                            new Container(
                              margin: const EdgeInsets.only(top:8),
                              child: new Text("热销榜单", style: new TextStyle(color: Color(0xff696969), fontSize: 10.0)),
                            )
                        ],
                      ),
                    ),
                  ),
                ),
                 new Container(
                  width: (MediaQuery.of(context).size.width - 6.0) / 5,
                  alignment: Alignment.center,
                  child: FlatButton(
                    onPressed: (){},
                    child: Container(
                      padding: const EdgeInsets.fromLTRB(0, 15, 0, 0),
                      child: new Column(
                        children: <Widget>[
                          new Container(
                              child: new Container(
                                width: 30,
                                height: 30,
                                child: new Image.asset('images/home/sort5.png'),
                              ),
                            ),
                            new Container(
                              margin: const EdgeInsets.only(top:8),
                              child: new Text("有品市集", style: new TextStyle(color: Color(0xff696969), fontSize: 10.0)),
                            )
                        ],
                      ),
                    ),
                  ),
                )
            ],
          ),
        );
  }

  // 路由传参&&接收返回的参数
  _backContext(BuildContext context)async{
    final result=await Navigator.push(context, 
      MaterialPageRoute(
        builder: (context)=>new DailProductPage(
          products:List.generate(
            20,
            (i)=>Product('商品 $i','这是一个商品详情，编号为:$i')
          )
        )
        )
    );
    Scaffold.of(context).showSnackBar(SnackBar(content:Text('$result')));
  }
}